<template>
  <el-dialog :title="tableTitle" v-model="props.dialogVisible" width="35%" top="15vh" center @open="tableOpen"
    :before-close="cancelClick">
    <div class="bodyBox">
      11111
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancelClick" :loading="btnLoading">关 闭</el-button>
      <el-button type="primary" @click="submitForm()" :loading="btnLoading">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script setup lang="ts">
import { ref, reactive, defineProps } from 'vue'
import cloneDeep from 'lodash/cloneDeep';
import { Delete } from '@element-plus/icons-vue'
import type { FormInstance, UploadProps } from 'element-plus'
const props = defineProps({
  dialogVisible: {
    type: Boolean,
    default: false,
  },
  tableLoading: {
    type: Boolean,
    default: false,
  },
  btnLoading: {
    type: Boolean,
    default: false,
  },
  tableTitle: {
    type: String,
    default: '',
  },
  ruleForm: {
    type: Array,
    default: () => [],
  },
  titleIDText: {
    type: String,
    default: '',
  },
  productKey: {
    type: String,
    default: '',
  },
})
const ruleFormRef = ref<FormInstance>()
// 弹窗打开事件
const tableOpen = () => {
  // Object.assign(ruleFormData, props.ruleForm);
}

const emits = defineEmits(['beforeClose', 'submitForm']);
// 确定按钮
const submitForm = () => {
  ruleFormData = cloneDeep(props.ruleForm)
  console.log(111, ruleFormData);
  // productKey
  ruleFormData = ruleFormData.map((item) => {
    return {
      ...item,
      product_key: props.productKey
    }
  })

  ruleFormData[0].lang = 'cn'
  ruleFormData[1].lang = 'en'
  if (!ruleFormData[0].style_name) {
    return ElMessage.error("请输入中文产品名称")
  }

  emits('submitForm', ruleFormData, props.tableTitle);
}
// 弹窗关闭事件
const cancelClick = () => {
  // 清空表单
  ruleFormRef.value?.resetFields();
  emits('beforeClose', false);
}
// 显式暴露方法给父组件
defineExpose({
  cancelClick
});
</script>
<style scoped lang="scss">
.titleID {
  width: 100%;
  display: inline-block;
  margin: 10px auto;
  text-align: right;
}

.tableCss {
  width: 100%;

  .doubleRow {
    color: #bababb;
  }
}

.imgUp {
  display: flex;
  justify-content: center;
  align-items: center;
}

:deep(.avatar-uploader .avatar) {
  width: 50px;
  height: 50px;
  display: block;
}

:deep(.avatar-uploader) {
  width: 55px;
  display: inline-block;
}
</style>
<style>
.avatar-uploader .el-upload {
  border: 1px dashed var(--el-border-color);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--el-transition-duration-fast);
}

.avatar-uploader .el-upload:hover {
  border-color: var(--el-color-primary);
}
</style>